﻿using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using XCore.Domain.Entities;

namespace SaaS.Model.Dto.Auths
{
    public class MenuChildren : IHasCreationTime
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Icon { get; set; }
        public string Path { get; set; }
        public string Name { get; set; }
        public bool IsVisble { get; set; }
        public string Component { get; set; }
        public string Redirect { get; set; }
        public bool AlwaysShow { get; set; }
        public DateTime CreationTime { get; set; }

        public IReadOnlyList<MenuChildren> Children => _children.ToImmutableList();

        private readonly List<MenuChildren> _children;
        public MenuChildren(int id, string name, string title, string component, string path, string icon,bool isVisble, DateTime creationTime, string redirect, bool alwaysShow)
        {
            this.Id = id;
            this.Name = name;
            this.Component = component;
            this.Path = path;
            this.Redirect = redirect;
            this.AlwaysShow = alwaysShow;
            this.Icon = icon;
            this.Title = title;
            this.IsVisble = isVisble;
            this.CreationTime = creationTime;
            _children = new List<MenuChildren>();
        }
        public MenuChildren CreateChildrenMenu(int id, string name, string title, string component, string path, string icon,bool isVisble,  DateTime creationTime, string redirect = null, bool alwaysShow = false)
        {
            var menu = new MenuChildren(id, name, title, component, path, icon, isVisble, creationTime, redirect, alwaysShow);
            _children.Add(menu);
            return menu;
        }
    }
}
